package com.itmk.config.web.sys_role.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itmk.config.web.sys_role.entity.RoleParm;
import com.itmk.config.web.sys_role.entity.SysRole;
import com.itmk.config.web.sys_role.mapper.SysRoleMapper;
import com.itmk.config.web.sys_role.service.SysRoleService;

import org.springframework.stereotype.Service;

@Service
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements SysRoleService {

// implements SysRoleService 实现我们自己的方法的原因是，原有的ServiceImpl不符合我们的增删改查的要求，需要自定义方法实现

    @Override
    public IPage<SysRole> getList(RoleParm parm) {
        //构造分页对象
        IPage<SysRole> page = new Page<>(parm.getCurrentPage(),parm.getPageSize());
        //构造查询条件
        QueryWrapper<SysRole> queryWrapper = new QueryWrapper<>();
        if (StringUtils.isNotEmpty(parm.getRoleName())) {
            //进行模糊查询
            queryWrapper.lambda().like(SysRole::getRoleName,parm.getRoleName());


        }
        return this.baseMapper.selectPage(page,queryWrapper);
    }

}
